<?PHP
$PurviewLevel=0;
require("../../inc/common.inc.php");
require_once(dirname(__FILE__)."/../"."Admin_ChkPurview.php");
if(intval($pagetype)==0){$pagetype=2;}
$poststr = "&type=".$type."&pagetype=".$pagetype."&keyword=".$keyword;
$poststr2 = "&type=".$type."&keyword=".$keyword;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<TITLE>铭讯EOS网站后台管理</TITLE>
<Meta name="Keywords" Content="济南网站建设 济南网站制作 山东网站建设 济南铭讯软件有限公司">
<Meta name="Description" Content="济南网站制作：铭讯软件专业服务优秀企业，致力于网站建、设网站推广、网络营销一体的全访位网络服务商">
<link href="../images/style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<?php require("../mx_head.php") ;
if ($action=="work"){
    //设置推荐
	if(!$listdb&&!$id){
		$fun->popmassage("请选择一条信息","","popback");
		exit();
	}
	elseif(is_array($listdb))
	{
		foreach($listdb AS $key=>$value){
			dowork($key,$jobs);
		}
	}elseif($id){
		dowork($id,$jobs);
	}
	$url=$fromurl?$fromurl:$FROMURL;
	jump2("操作成功",$url,1);

}

function dowork($id,$job){
	global $db,$pre,$timestamp,$userdb,$webdb,$fiddbadmin,$Purview,$fun,$OtherPurview,$Purview,$usersql;
	$rsdb=$db->get_one("SELECT * FROM mx_sucai_app WHERE aid='$id'");
	if($job=="delete")
	{
	    if (strpos("****".$OtherPurview,'shenhe')<=0 and $Purview!=1 and $Purview!=3){
		    $fun->popmassage("您没有此项管理权限","","popback");
		    exit();
		}
		$db->excu("DELETE FROM mx_sucai_app WHERE aid='$id'");
	}
}
?>
	<div class="right">
	  <div class="gk">
			<div class="ti1 fl">APP库</div>
			<ul class="fr">
				<li><span class="c1"><?php echo $db->num_rows($db->excu("select aid from mx_sucai_app"));?></span><span>信息总条数</span></li>
			</ul>
			<div class="clear"></div>
	  </div>
		<div class="height15"></div>
		<div class="xm2">
			<h1 class="fl">信息列表</h1>
			<!--<span class="fr"><a href="#"><img src="../images/right_4.png" alt="设置" /></a></span>-->
		</div>
        
		<div class="xm2_b">
        <div class="t">
				<div><input type="button" class="button" value="信息管理">&nbsp;<input type="button" class="button2" value="添加信息" onclick="window.location='sucai_app_add.php'"></div>
				<div class="clear"></div>
			</div>
			<div class="t">
				<div class="l1 fl"><select onChange="javascript:window.location=this.value;"><option value="sucai_app.php?pagetype=1<?php echo $poststr2;?>" <?php echo $pagetype==1?'selected="selected"':'';?>>10</option><option value="sucai_app.php?pagetype=2<?php echo $poststr2;?>" <?php echo $pagetype==2?'selected="selected"':'';?>>20</option></select></div>
				<div class="l2 fl">选择每页的信息数量，默认值为：20条/页。</div>
				<div class="l3 fr"><div class="l">快速检索: </div><div class="r"><input name="keyword" type="text" value="<?php echo $keyword;?>" onkeydown="setTrack(this,event)" /></div></div>
				<div class="clear"></div>
			</div>
			<div class="height15"></div>
				<script type="text/javascript" src="../js/jquerys-1.5.1.js"></script>
				<script language="javascript">
				function setTrack(tt,event){
				var e = event?event:window.event
				if(e.keyCode == 13){
				window.location="sucai_app.php?type=title&pagetype=<?php echo $pagetype;?>&keyword="+tt.value;
				}
				}
				</script>
				<script language="javascript">
				$(document).ready(function(){ //这个就是传说的ready   
				$(".stripe tr").mouseover(function(){   
				//如果鼠标移到class为stripe的表格的tr上时，执行函数   
				$(this).addClass("over");}).mouseout(function(){   
				//给这行添加class值为over，并且当鼠标一出该行时执行函数   
				$(this).removeClass("over");}) //移除该行的class   
				$(".stripe tr:even").addClass("alt");   
				//给class为stripe的表格的偶数行添加class值为alt
				//www.divcss5.com 整理特效
				});   
				</script> 
                <script language="javascript">
				function postdo(va){
					if (va=="delete"){
						if(!confirm("您确认要删除这些记录吗?")){
						return false;
						}
					}
					document.form1.jobs.value=va
					document.form1.submit();
				}
				
				function CheckAll(va,zt){
					form=document.form1
					for (var i=0;i<form.elements.length;i++){
						var e = form.elements[i];
						if(va=='all'){
							e.checked = zt;
						}else{
							e.checked == true ? e.checked = false : e.checked = true;
						}
					}
				}
				function subform(){
						 if(document.all.type.value==""){
							alert("请选择查询条件！");
							return false;
						 }
						document.form2.submit();
				}
				</script>
                <form name="form1" action="sucai_app.php?action=work<?php echo $poststr;?>" method="post">
                <input type="hidden" name="jobs" value="">
			<table width="98%" border="0" align="center" cellpadding="9" cellspacing="1" bgcolor="#CCCCCC" class="stripe">
			  <tr>
				<th width="4%" align="center" ><input type="checkbox" name="checkbox" class="ri" onClick="CheckAll('all',this.checked)" /></th>
				<th width="4%" align="center" class="table_ti">ID</th>
                <th width="15%" align="center" class="table_ti">信息类型</th>
				<th align="center" class="table_ti">标题</th>
                <th width="10%" align="center" class="table_ti">添加时间</th>
				<th width="17%" align="center" class="table_ti">操作</th>
			  </tr>
              <?php
			  if(empty($pageindex)){$pageindex=1;}
			  $str="";
			  if($type=="yz"){
				  $str.=" AND isok=1 ";
			  }
			  elseif($type=="unyz"){
				  $str.=" AND isok=0 ";
			  }
			  elseif($type=="title"){
				  $str.=" AND atitle LIKE '%$keyword%' ";
			  }
			  $order="order by addtime desc, aid desc";
			  $pagesize = $pagetype==1?"10":"20";
			  $table=" mx_sucai_app ";
			  $column=" * ";
			  $c=$db->listcount($table,$str);
			  $list=$db->list1($pageindex,$pagesize,$table,$column,$str,$order);
			  if(!is_array($list) or $c==0){
				echo "<tr><td colspan='10'><p style='height:30px;text-align:center;line-height:30px;'>暂无信息</p></td></tr>";
			  }
			  else{
			  for($i=0;$i<count($list);$i++){
			  ?>
			  <tr>
				<td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="listdb[<?php echo $list[$i]["aid"];?>]" value="<?php echo $list[$i]["aid"];?>" class="ri" /></td>
				<td align="center" bgcolor="#FFFFFF" class="font14"><?php echo $list[$i]["aid"];?></td>
				<td align="center" bgcolor="#FFFFFF" class="font14">
                <?php 
				switch($list[$i]["atype"]){
					case 1;echo"HTML";break;
					case 2;echo"文字";break;
					case 3;echo"链接";break;
				}
				?>
                </td>
				<td align="left" bgcolor="#FFFFFF" class="font14"><a href="sucai_app_edit.php?id=<?php echo $list[$i]["aid"];?>"><?php echo wordscut($list[$i]["atitle"],50,"...")?></a></td>
				<td align="center" bgcolor="#FFFFFF" class="font12"><?php echo date("Y-m-d",$list[$i]["addtime"])?></td>
				<td align="left" bgcolor="#FFFFFF"><a href="sucai_app_edit.php?id=<?php echo $list[$i]["aid"];?>">编辑</a>&nbsp;&nbsp;<a href="sucai_app.php?action=work&jobs=delete&id=<?php echo $list[$i]["aid"]?><?php echo $poststr;?>" onClick="return confirm('删除后不可恢复,你确实要删除吗?')">删除</a><?php echo $mtypestr;?></td>
			  </tr>
			  <?php
			  }
			  }
			  ?>
			</table>
            </form>
			<div class="height15"></div>
			<div class="b">
				<div class="l fl"><input name="" type="checkbox" onClick="CheckAll('all',this.checked)" /></div>
				<div class="c fl">批量选择</div>
				<div class="r fl">选择操作：<a href="javascript:void(0)" onClick="postdo('delete')">全部删除</a><input type="hidden" name="jobs" value="0"></div>
			</div>
			<div class="height15"></div>
			<div class="pagination">
				<?php if ($c>$pagesize){echo $db->ThePage_mxsoft($s,$pageindex,$c,$pagesize,'','',0,4,''.$poststr.'');}?>
			</div>
            <div class="clear"></div>
			<div class="height15"></div>
		</div>
        
		<div class="clear"></div>
   <?php require("../mx_foot.php") ;?>
  </div>
</body>
</html>